package tx.bj12320.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.junit.Test;

import cn.org.rapid_framework.test.context.TestMethodContext;
import static junit.framework.Assert.*;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bj12320.model.*;
import tx.bj12320.dao.*;
import tx.bj12320.service.*;
import tx.bj12320.vo.query.*;


public class ActivityInfoManagerTest extends BaseManagerTestCase{

	private ActivityInfoManager manager;
	
	@Autowired
	public void setActivityInfoManager(ActivityInfoManager manager) {
		this.manager = manager;
	}

    @Override
    protected String[] getDbUnitDataFiles() {
        //通过 TestMethodContext.getMethodName() 可以得到当前正在运行的测试方法名称
        return new String[]{"classpath:testdata/common.xml","classpath:testdata/ActivityInfo.xml",
                            "classpath:testdata/ActivityInfo_"+TestMethodContext.getMethodName()+".xml"};
    }

	//数据库单元测试前会开始事务，结束时会回滚事务，所以测试方法可以不用关心测试数据的删除
	@Test
	public void crud() {

		ActivityInfo obj = newActivityInfo();
		manager.save(obj);
		manager.getEntityDao().flush();
		
		manager.update(obj);
		manager.getEntityDao().flush();
		
		assertNotNull(obj.getActivityInfoId());
		
		manager.removeById(obj.getActivityInfoId());
		manager.getEntityDao().flush();
	
	}
	
	public static ActivityInfo newActivityInfo() {
		ActivityInfo obj = new ActivityInfo();
		
	  	obj.setTszbProcessInfoId(new Long("1"));
	  	obj.setUserInfoId(new Long("1"));
	  	obj.setOperatorName(new java.lang.String("1"));
	  	obj.setReceiveTime(new java.util.Date(System.currentTimeMillis()));
	  	obj.setFinishTime(new java.util.Date(System.currentTimeMillis()));
	  	obj.setOpin(new java.lang.String("1"));
	  	obj.setActivityName(new java.lang.String("1"));
	  	obj.setActivityInstId(new Long("1"));
	  	obj.setIncomingCallContent(new java.lang.String("1"));
		return obj;
	}
}
